<html>
<head>
	<TITLE>Cập nhật thông tin cá nhân</TITLE>	
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
   	$(document).ready(function(){
		$("#birthday").datepicker({dateFormat:"yy-mm-dd"});
		//$("#modified_date").datepicker({dateFormat:"yy-mm-dd"});
		//$("#created_date").datepicker({dateFormat:"yy-mm-dd"});
		load_accounttype();
		loadInfoUser();
		$('#status1').hide();
		$('#status2').hide();
        //load_menu_list(1);
        //load_listpage(1);
	});
   
   	function loadInfoUser(){
		var data='';
		$.getJSON("data/system/account/user_info/get_userinfo.php",data, function(data){ 
				$("#username").val(data.username); 
				$("#password").val(data.password); 
				$("#first_name").val(data.first_name);
				$("#last_name").val(data.last_name); 
				$("#birthday").val(data.birthday);
				$("#address").val(data.address);
				$("#mobi").val(data.mobi);
				$("#tell").val(data.tell);
				var sex=data.sex;
				if(sex==1) $("#rdSEXM").attr("checked",true);
				else $("#rdSEXF").attr("checked",true);
				var status=data.status;
				if(status==0) $("#status1").attr("checked",true);
				else $("#status2").attr("checked",true)
				$("#room_number").val(data.zoom_number);
				$("#email").val(data.email);
				$("#level").val(data.level);
				$("#fax").val(data.fax);
				$("#modified_date").val(data.modified_date);
				$("#created_date").val(data.created_date);
				$("#created_by").val(data.created_by);
				$("#partner_id").val(data.partner_id);
				//alert($("#partner_id").val());
				
		}); 
	}
    function load_accounttype(){
            var path ='';
            $.ajax({
      			type:"POST",
      			url: "data/system/account/user_info/get_list_accounttype.php",
      			data: path,
                async: false,
    			success: function(data) {                   
                        $("#combox_accounttype").html(data);        
			     }
		     }); 
	}
	function update_userinfo(){
			 var username =$('#username').val();
			 var password =$('#password').val();
			 var first_name =$('#first_name').val();
			 var last_name =$('#last_name').val();
			 var birthday =$('#birthday').val();
			 var address =$('#address').val();
			 var mobi = $('#mobi').val();
			 var tell = $('#tell').val();
			 var room_number = $('#room_number').val();
			 var email = $('#email').val();
			 var level=$('#level').val();
			 var modified_date =$('#modified_date').val();
			 var created_date = $('#created_date').val();
			 var created_by =$('#created_by').val();
			 var fax =$('#fax').val();
			 var sex=0;
			 if($("#rdSEXM").attr("checked"))  sex=1;
			 var status=0;
			 if($("#status2").attr("checked"))  status=1;
			 var partner_id = $('#partner_id').val();
			 var path='username='+username+'&password='+password+'&first_name='+first_name+'&last_name='+last_name+'&birthday='+birthday+
			 			'&address='+address+'&mobi='+mobi+'&tell='+tell+'&room_number='+room_number+'&email='+email+'&level='+level+                        '&modified_date='+modified_date+'&created_date='+created_date+'&created_by='+created_by+'&fax='+fax+'&sex='+sex+                        '&status='+status+'&partner_id='+partner_id;
			 alert(path);
             $.ajax({
      			type:"POST",
      			url: "data/system/account/user_info/edit_user_info.php",
      			data: path,
                async: false,
    			success: function(data) {  
						 alert(data); 
						 if(data==1) _alert('inform','Cập nhật thông tin thành công!');              
                         else _alert('inform','Cập nhật thông tin không thành công!');
						 load_accounttype();
						 loadInfoUser();
			     }
		     }); 
		
	}
   </script>
</head>
<BODY>
<div id='tabheader' class="header">Quản lý hệ thống &nbsp;<img height="7px" src="lib/images/left.png">&nbsp; Thông tin cá nhân </div>
<div>
	<fieldset class="field_set">
		<legend>Thong tin ca nhan</legend>
		<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 class="ctable" style="padding-right:50px;">
		  <TBODY>
			  <TR>
				<TD width="15%" style="padding-left:50px;">Tên truy cập <font color="#FF0000">*</font> : </TD>
				<TD style="VERTICAL-ALIGN: top; PADDING-TOP: 4px" width="25%">
					<input id="username" class=cinput type="text" style="WIDTH: 100%" name="USERID" readonly></TD>
				<TD width="15%" style="padding-left:50px;">Mật khẩu <font color="#FF0000">* </font>:</TD>
				<TD width="25%"><input id="password" class=cinput type="password" style="WIDTH: 100%" name="password" readonly></TD></TR>
			  <TR>
				<TD style="padding-left:50px;">Họ<font color="#FF0000">&nbsp; </font><font color="#FF0000">&nbsp;*</font> : </TD>
				<TD>
					<input id="first_name"  class=cinput type="text" style="WIDTH:100%" name="first_name" ></TD>
				<TD style="padding-left:50px;">Tên : </TD>
				<TD width="212" ><input id="last_name"  class=cinput type="text" style="WIDTH: 100%" name="last_name" >
				</TD>
				</TR>

			  <TR>
				<TD style="padding-left:50px;">Ngày sinh <font color="#FF0000">*</font> : </TD>
				<TD >
					<input style="WIDTH:70%" class="cdate" type="text" name="birthday" id="birthday" />
				</TD>
				<TD style="padding-left:50px;">
				
				Địa chỉ <font color="#FF0000">*</font> :
				</TD>
				<TD width="212">
					<input id="address" class=cinput type="text" style="WIDTH: 100%" name="ADDRESS" ></TD></TR>
			  <TR>
				<TD style="padding-left:50px;">Số di động <font color="#FF0000">*</font> : </TD>
				<TD >
					<input id="mobi" class=cinput type="text" style="WIDTH: 100%" name="MOBILE" ></TD>
				<TD style="padding-left:50px;">Giới tính<font color="#FF0000">* </font>:</TD>
				<TD width="212" >
					<input id="rdSEXM" type="radio" value="1" name="sex">Nam
					<input id="rdSEXF" type="radio" value="2" name="sex">Nữ
				</TD></TR>
				<tr>
				<TD style="padding-left:50px;">Số cố định<font color="#FF0000">*</font> : </TD>
				<TD>
					<input id="tell" class=cinput type="text" style="WIDTH: 100%" name="TEL" ></TD>
				<TD style="padding-left:50px;">Số phòng :</TD>
				<TD width="212">
					<input id="room_number" class=cinput type="text" style="WIDTH: 100%"  name="room_number"></TD>
				</tr>
				<tr>
				<TD style="padding-left:50px;">Email <font color="#FF0000">*</font> :</TD>
				<TD>
					<input id="email" class=cinput type="text" style="WIDTH: 100%"  name="EMAIL" ></TD>
				<TD style="padding-left:50px;">Quyền</TD>
				<TD width="212"><div id="combox_accounttype" ></div></TD>
				</tr>
				<tr>
				  <TD style="padding-left:50px;">Người tạo :</TD>
				  <TD id="tdCREATED_BY_"><input type="text" id="created_by" class="cinput" style="width:100%" readonly></TD>
				<TD style="padding-left:50px;">Ngày sửa đổi:</TD>
				<TD id="modified_date_"><input type="text" class="cdate" style="width:100%"  id="modified_date" readonly></TD>
				</tr>
				<tr>
				  <TD style="padding-left:50px;"> Ngày tạo:</TD>
				  <TD id="tdCREATED_DATE_"><input type="text" id="created_date" class="cdate" style="width:100%" readonly></TD>
				<TD style="padding-left:50px;">&nbsp;</TD>
				<TD id="tdCREATED_DATE_" width="212">&nbsp;</TD>
				</tr>
				<tr>
				<TD style="padding-left:50px;">&nbsp;</TD>
				<TD id="tdCREATED_BY_">&nbsp;</TD>
				<TD></TD>
				<TD ></TD>
				</tr>
				<tr>
					 <TD colspan="4" align="center"><div id='inform'></div></TD>
				</tr>
				<tr>
					<TD colspan="4" align="center">
					<div class="padding5"></div>
					<INPUT id='cmdOK' style="width:200"  type=button value="Cập nhật thông tin" onClick="update_userinfo()" class="gra_button green"></TD>
				</TD>
				</tr>
			</TBODY>
		</TABLE>
		<input id='partner_id' type="hidden" />
	</fieldset>
    <input id="fax" class=cinput type="hidden" style="WIDTH: 100%"  name="fax" >
    <input id="status1" disabled type="radio" value="0" name="STATUS">
	<input id="status2" disabled  type="radio" value="1" name="STATUS">
</div>
</BODY>
</HTML>